from rest_framework.generics import GenericAPIView
from rest_framework import mixins
from rest_framework import generics
from .serializers import UserInfoSerializer, AddrSerializer
from .models import UserInfo, Addr


class UserListView(generics.ListAPIView,
                   generics.CreateAPIView):
    # 模型类指定
    queryset = UserInfo.objects.all()
    # 序列化器指定
    serializer_class = UserInfoSerializer


class UserDetailView(generics.RetrieveAPIView,
                     generics.DestroyAPIView,
                     generics.UpdateAPIView):
    # 模型类指定
    queryset = UserInfo.objects.all()
    # 序列化器指定
    serializer_class = UserInfoSerializer


# 收货地址增删查改
class AddrListView(generics.ListAPIView,
                   generics.CreateAPIView):
    # 模型类指定
    queryset = Addr.objects.all()
    # 序列化器指定
    serializer_class = AddrSerializer


class AddrDetailView(generics.RetrieveAPIView,
                     generics.DestroyAPIView,
                     generics.UpdateAPIView):
    # 模型类指定
    queryset = Addr.objects.all()
    # 序列化器指定
    serializer_class = AddrSerializer
